CFLAGS = -fpic -coverage -lm -std=c99 -ftest-coverage -fprofile-arcs

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

testShuffle: testShuffle.c rngs.o dominion.o
	gcc testShuffle.c rngs.o dominion.o -o testShuffle $(CFLAGS)

runtests: testDrawCard 
	./testDrawCard &> unittestresult.out
	gcov dominion.c >> unittestresult.out
	cat dominion.c.gcov >> unittestresult.out

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

unitTests: dominion.o rngs.o
	echo "By Danny Burrows" > unittestresults.out
	echo "--Results for all unit tests--" >> unittestresults.out

	echo "unittest1.c" >> unittestresults.out
	gcc -o unittest1 unittest1.c dominion.o rngs.o $(CFLAGS)
	./unittest1.exe >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out

	echo "unittest2.c" >> unittestresults.out
	gcc -o unittest2 unittest2.c dominion.o rngs.o $(CFLAGS)
	./unittest2.exe >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out

	echo "unittest3.c" >> unittestresults.out
	gcc -o unittest3 unittest3.c dominion.o rngs.o $(CFLAGS)
	./unittest3.exe >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	
	echo "unittest4.c" >> unittestresults.out
	gcc -o unittest4 unittest4.c dominion.o rngs.o $(CFLAGS)
	./unittest4.exe >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	
	echo "cardtest1.c" >> unittestresults.out
	gcc -o cardtest1 cardtest1.c dominion.o rngs.o $(CFLAGS)
	./cardtest1.exe >> unittestresults.out
	gcov dominion.c >> test.out
	gcov -b dominion.c >> unittestresults.out

	echo "cardtest2.c" >> unittestresults.out
	gcc -o cardtest2 cardtest2.c dominion.o rngs.o $(CFLAGS)
	./cardtest2.exe >> unittestresults.out
	gcov dominion.c >> test.out
	gcov -b dominion.c >> unittestresults.out
	
	echo "cardtest3.c" >> unittestresults.out
	gcc -o cardtest3 cardtest3.c dominion.o rngs.o $(CFLAGS)
	./cardtest3.exe >> unittestresults.out
	gcov dominion.c >> test.out
	gcov -b dominion.c >> unittestresults.out
	
	echo "cardtest4.c" >> unittestresults.out
	gcc -o cardtest4 cardtest4.c dominion.o rngs.o $(CFLAGS)
	./cardtest4.exe >> unittestresults.out
	gcov dominion.c >> test.out
	gcov -b dominion.c >> unittestresults.out

randomtests: dominion.o rngs.o
	gcc -o randomtestadventurer randomtestadventurer.c dominion.o rngs.o $(CFLAGS)
	./randomtestadventurer.exe > randomtestadventurer.out
	gcov -b dominion.c >> randomtestadventurer.out

	gcc -o randomtestcard randomtestcard.c dominion.o rngs.o $(CFLAGS)
	./randomtestcard.exe > randomtestcard.out
	gcov -b dominion.c >> randomtestcard.out

all: playdom player testDrawCard testBuyCard badTestDrawCard

clean:
	rm -f *.o playdom.exe playdom test.exe test player player.exe testInit testInit.exe *.gcov *.gcda *.gcno *.so
